package com.xbts.web.controller.system;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.xbts.common.annotation.Log;
import com.xbts.common.core.controller.BaseController;
import com.xbts.common.core.domain.AjaxResult;
import com.xbts.common.core.page.TableDataInfo;
import com.xbts.common.enums.BusinessType;
import com.xbts.system.domain.CnHwyTemplate;
import com.xbts.system.domain.dto.CnHwyTemplateTopDTO;
import com.xbts.system.service.ICnHwyTemplateService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.validation.Valid;
import java.util.ArrayList;
import java.util.List;

/**
 * @author : llk
 * @Date: 2024/4/10 10:56
 */
@Api(tags = "华为云模板管理")
@RequestMapping("/user/hwy_template")
@RestController
public class CnHwyTemplateController extends BaseController {

    @Resource
    private ICnHwyTemplateService hwyTemplateService;

    /**
     * 获取华为云模板列表
     */
    @ApiOperation("获取华为云模板列表")
    @GetMapping("/list")
    public AjaxResult list() {
        Page<CnHwyTemplate> page = hwyTemplateService.page(new Page<>(1, 2), new LambdaQueryWrapper<CnHwyTemplate>().orderByDesc(CnHwyTemplate::getIsTop));
        if (page.getTotal() > 0) {
            return success(page.getRecords());
        }
        return success(new ArrayList<>(0));
    }

}
